﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace hm_restaurant.View
{
    public partial class Frm_printer_add : Form
    {
        public Frm_printer_add()
        {
            InitializeComponent();
        }

        public void init(string id1,string location1,string pageSize1,string ip1,Boolean active1)
        {
            ip = ip1;
            location = location1;
            pageSize = pageSize1;
            ip = ip1;
            active = active1;
        }

        public string id { get; set; }

        public string location { get; set; }

        public string interfaces { get; set; }

        public string pageSize { get; set; }

        public string ip { get; set; }

        public Boolean active = false;


        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ip = textBox1.Text;
            if (string.IsNullOrEmpty(ip))
            {
                MessageBox.Show("ip地址不能为空");
                return;
            }
            location = comboBox1.SelectedValue.ToString();
            interfaces = comboBox2.SelectedValue.ToString();
            pageSize = comboBox3.SelectedValue.ToString();
            if (radioButton1.Checked)
            {
                active = true;
            }
            else
            {
                active = false;
            }


            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void Frm_printer_add_Load(object sender, EventArgs e)
        {
            DataTable dt1 = new DataTable();
            dt1.Columns.Add("id");
            dt1.Columns.Add("name");
            DataRow r1=dt1.NewRow();
            r1["id"] = 1;
            r1["name"] = "订单1";
            dt1.Rows.Add(r1);

            r1 = dt1.NewRow();
            r1["id"] = 2;
            r1["name"] = "订单2";
            dt1.Rows.Add(r1);
            comboBox1.DataSource = dt1;
            comboBox1.DisplayMember = "name";
            comboBox1.ValueMember = "id";
            select_combo1();


            DataTable dt2 = new DataTable();
            dt2.Columns.Add("id");
            dt2.Columns.Add("name");
            DataRow r2 = dt2.NewRow();
            r2["id"] = 1;
            r2["name"] = "网口";
            dt2.Rows.Add(r2);
            comboBox2.DataSource = dt2;
            comboBox2.DisplayMember = "name";
            comboBox2.ValueMember = "id";
            select_combo2();

            DataTable dt3 = new DataTable();
            dt3.Columns.Add("id");
            dt3.Columns.Add("name");
            DataRow r3 = dt3.NewRow();
            r3["id"] = 1;
            r3["name"] = "80";
            dt3.Rows.Add(r3);
            comboBox3.DataSource = dt3;
            comboBox3.DisplayMember = "name";
            comboBox3.ValueMember = "id";
            select_combo3();

            textBox1.Text = ip;

            if (active)
            {
                radioButton1.Checked = true;
            }
            else
            {
                radioButton2.Checked = true;
            }



        }


        private void select_combo1() {


        }

        private void select_combo2()
        {


        }

        private void select_combo3()
        {
            

        }

    }
}
